﻿using System;
using System.Collections.Generic;
using System.Text;
using KKCai.TV.Model;

namespace KKCai.TV.DAL
{
    public class DayCountDao : Core.AbstractDao<DayCountInfo>
    {
        private const string hql = "select c.Value from DayCountInfo c";

        public IList<int> List()
        {
            return Session.CreateQuery(hql).List<int>();
        }

        public int Update(string result)
        {
            string hql = String.Format("update DayCount set Value = Value + 1 where ID in ( {0} )", result.Replace(" ", ","));

            return Session.CreateSQLQuery(hql).ExecuteUpdate();
        }

        public int Reset()
        {
            string hql = "update DayCount set Value = 0";

            return Session.CreateSQLQuery(hql).ExecuteUpdate();
        }
    }
}
